const service = require('../service/comment.service')
class CommentController {
    async create(ctx, next) {
        const { momentId, content } = ctx.request.body
        const { id } = ctx.user
        const result = await service.create(momentId, content, id)
        ctx.body = result
    }
    async reply(ctx, next) {
        const { momentId, content, commentId } = ctx.request.body
        console.log(momentId)
        const { id } = ctx.user
        const result = await service.reply(momentId, content, id, commentId)
        ctx.body = result
    }
    async update(ctx, next) {
        const { commentId } = ctx.params
        const { content } = ctx.request.body

        const result = await service.update(commentId, content)

        ctx.body = result
    }
    async list(ctx, next) {
        const { momentId } = ctx.params
        const result = await service.getCommentByMomentId(momentId)
        ctx.body = result
    }
    async replycomment(ctx, next) {
        const { content, momentId, commentId,
            reply_comment_id, target_user_name } = ctx.request.body

        const { id } = ctx.user
        const result = await service.replycomment(content, momentId, commentId,
            reply_comment_id, target_user_name, id)
        ctx.body = result
    }


}
module.exports = new CommentController()